package cn.buddha.jesj.callback;

import lombok.Builder;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.TimeUnit;

/**
 * @ClassName Calc
 * @Author 友野浩二
 * @Date 2019/11/17 11:25
 * @Description 计算类型类
 * @Version 1.0
 */
@Builder
@Slf4j
public class Calc {

    public void getAnswer(final String calcType, final BaseCallbackService baseCallbackService) {
        switch (calcType) {
            case "ST-CB":
                // 回调baseCallbackService.callback()方法
                baseCallbackService.callback(calcType, "我是学生ST-CB啊!");
                break;
            case "WO":
                baseCallbackService.callback(calcType, "我是工人啊!");
                break;
            case "ST-ASK":
                for (int i = 1; i <= 3; i++) {
                    try {
                        TimeUnit.SECONDS.sleep(1);
                    } catch (InterruptedException e) {
                        log.error("ST-ASK异常: ", e);
                    }
                }
                baseCallbackService.callback(calcType, "我是学生ST-ASK啊!");
                break;
            default:
                baseCallbackService.callback(calcType, "我布吉岛啊!");
                break;
        }
    }

}
